<?php
/**
 * Created by PhpStorm.
 * User: aiChenK
 * Date: 2018-12-26
 * Time: 11:23
 */

namespace Services\Sys;

interface PowerInterface
{

    /**
     * 检查是否有权限
     * todo 支持多权限判断
     *
     * @param $powerTag
     * @param null $targetId    -- userId(默认)|groupId
     * @param null $type        -- user(仅用户)|group(仅组)|all(默认)
     * @return bool
     **/
    public static function exist($powerTag, $targetId = null, $type = null);

    /**
     * 获取权限标识列表（默认合并用户组）
     * 静态保存，登陆用户保存至session
     *
     * @param null $targetId
     * @param null $type
     * @return mixed
     */
    public static function getPowerTags($targetId = null, $type = null);

    /**
     * 获取扩展权限id
     *
     * @param $type
     * @param $target
     * @param null $userId
     * @return array|bool|mixed     --[1,2,3] | [] | true
     */
    public static function getExtraPower($type, $target, $userId = null);

    /**
     * 获取扩展管理权限id
     *
     * @param $type
     * @param $target
     * @param null $userId
     * @return array|bool|mixed
     */
    public static function getManageExtraPower($type, $target, $userId = null);

    /**
     * 判断是否有管理权限
     *
     * @param $type
     * @param $target
     * @param $id
     * @param bool $manage
     * @return bool
     */
    public static function hasExtra($type, $target, $id, $manage = false);
}
